<template>
  <div id="app">
    <div id="nav">
      <router-link to="/"></router-link>
    </div>
    <div v-if="this.$route.path!=='/login' && this.$route.path!=='/register' && this.$route.path!=='/change'">
      <div>
        <div class="title1">{{this.$route.name}}</div>
        <el-menu
          :default-active="
        activeIndex"
          class="el-menu-demo"
          mode="horizontal"
          @select="handleSelect"
          router
          style="margin:0 auto;width:452px"
        >
          <el-menu-item index="/home">首页</el-menu-item>
          <el-menu-item index="/list">商品清单</el-menu-item>
          <el-menu-item index="/announcement">网站公告</el-menu-item>
          <el-menu-item index="4">关于我们</el-menu-item>
          <el-menu-item index="5">联系我们</el-menu-item>
        </el-menu>
        <div class="line"></div>
      </div>
      <div class="user">
        <span>欢迎您,</span>
        <el-avatar
          class="header-img"
          :size="40"
          src="https://ae01.alicdn.com/kf/Hd60a3f7c06fd47ae85624badd32ce54dv.jpg"
          style="cursor: pointer;"
          @click.native=gouserdetail
        ></el-avatar>
        <span>{{this.$store.state.user[0].username}}</span>
      </div>
    </div>
    <router-view />
  </div>
</template>
<script>
export default {
  created() {
    // this.user = this.$store.state.user[0]
    console.log(this.$route.path)
    this.activeIndex = this.$route.path
  },
  data: () => ({
    activeIndex: '/home',
    activeIndex2: '1'
  }),
  methods: {
    handleSelect(key, keyPath) {
      console.log(key, keyPath)
    },
    gouserdetail() {
      console.log(1)
      this.$router.push('/userdetail')
    }
  }
}
</script>
<style lang="scss" scoped>
.title1 {
  font-size: 20px;
  font-weight: bold;
  text-align: center;
  margin-top: 20px;
}
.user {
  font-size: 13px;
  position: absolute;
  right: 20px;
  top: 20px;
}
</style>
